package devcken.net.socket;

import java.util.HashMap;
import java.util.Map;

public enum EncryptionOptions
{
	/**
	 * 데이터를 암호화하지 않는다.
	 */
	None(0x00),
	
	/**
	 * Triple DES 방식으로 데이터를 암호화한다.
	 */
	TripleDes(0x01);
	
	public final byte value;
	
	public final static int Size = Byte.SIZE;
	
	private static final Map<Byte, EncryptionOptions> _map = new HashMap<Byte, EncryptionOptions>();
	
	static
	{
		for (EncryptionOptions item : EncryptionOptions.values())
		{
			_map.put(item.value, item);
		}
	}
	
	private EncryptionOptions(int value)
	{
		this.value = (byte)value;
	}

	public byte value()
	{
		return this.value;
	}
	
	public static EncryptionOptions convert(byte value)
	{
		return _map.get(value);
	}
	
	public static boolean convert(byte value, EncryptionOptions encryptionOption)
	{
		boolean result = _map.containsKey(value);
		
		if (result)
		{
			encryptionOption = _map.get(value);
		}
		
		return result; 
	}
}